/*
 * @Author: szx
 * @Date: 2022-06-09 14:35:24
 * @LastEditTime: 2022-06-09 14:40:00
 * @Description:
 * @FilePath: \leetcode\面试题\16\16\16.js
 */
/**
 * @param {number[]} array
 * @return {number[]}
 */
 var subSort = function (array) {
    const arr = Array.from(array).sort((a, b) => a - b);
    let l = 0,
        r = arr.length - 1;
    while (l <= r) {
        if (arr[l] != array[l]) break;
        l++;
    }
    while (l <= r) {
        if (arr[r] != array[r]) break;
        r--;
    }
    if (l >= r) return [-1, -1];
    return [l, r];
};
